var login = toContextPath('/student/student_login.action');
var indexHtml = toContextPath('/StuPages/index.html');

$(function(){
	initSubmit();
});
function validateEmail(email) {
	//var reg = "/^[a-zA-Z]{2}[a-zA-Z0-9]{1,6}@mail.ustc.edu.cn$/";
	if (email.match(/^[a-zA-Z]{2}[a-zA-Z0-9]{1,6}@mail.ustc.edu.cn$/) != null) {
        $("#emailHint").css("display", "none");
        $("#emailOk").css("display", "inline");
    }
}

function validatePwd(pwd) {
    if (pwd.match(/^[a-zA-Z0-9]{6,12}$/) != null) {
        $("#pwdOk").css("display", "inline");
    }
}
function Account(email, pwd) {
    this.email = email;
    this.pwd = pwd;
}
function submitClick() {
    var email=$("#userEmail").value;
    var pwd = $("#userPwd").value;
    var account = new Account(email, pwd);
}

function indexJs() {
	var para = getParameter();
//	console.log('para: ' + para);
	location.hash = '';
	if (para.result.stuName) {
		$('#stuName').html(para.result.stuName);
	}
}

function initSubmit() {
	$('#btn_submit').click(function(){
		// submit
		$('#ContactForm').form({
			url: login,
			success: function(result) {
				var data = $.parseJSON(result);
				if(data.result == "1") {
					//loadHtml(indexHtml);
					window.location.href = indexHtml;
				}		
				else
					alert('login failed!');
			}
		});
	});
}


//$("#userPwd").formValidator();